package com.xci.xajtfb.bus.api;

import com.github.lvyanyang.annotation.Authorize;
import com.github.lvyanyang.core.BaseController;
import com.github.lvyanyang.core.BoolResult;
import com.github.lvyanyang.core.Const;
import com.github.lvyanyang.core.PageList;
import com.xci.xajtfb.bus.entity.BaseFile;
import com.xci.xajtfb.bus.filter.BaseFileFilter;
import com.xci.xajtfb.bus.service.BaseFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统文件接口
 * @author 张谦 765870682@qq.com
 * @since 2021-03-02 9:40:00
 */
@Authorize
@RestController
@Api(tags = "系统文件接口")
@RequestMapping(value = "/api/bus/baseFile", produces =  Const.PROJSON)
public class BaseFileApiController extends BaseController {
    /**
     * 系统文件服务
     */
    @Resource
    private BaseFileService baseFileService;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新建系统文件")
    //@Authorize(code = "basic.baseFile.insert")
    @PostMapping("/insert")
    public BoolResult insert(@RequestBody BaseFile entity) {
        return baseFileService.insert(entity);
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "根据主键字符串删除系统文件")
    @ApiImplicitParam(name = "ids", value = "主键字符串,多个逗号隔开", required = true)
    //@Authorize(code = "basic.baseFile.delete")
    @PostMapping("/delete")
    public BoolResult delete(String ids) {
        return baseFileService.delete(ids);
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "根据主键查询单个系统文件")
    @ApiImplicitParam(name = "id", value = "系统文件主键", required = true)
    //@Authorize(code = "basic.baseFile.select")
    @PostMapping("/selectById/{id}")
    public BoolResult<BaseFile> selectById(@PathVariable String id) {
        return BoolResult.success(baseFileService.selectById(id));
    }

    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "查询系统文件列表")
    //@Authorize(code = "basic.baseFile.select")
    @PostMapping("/selectList")
    public BoolResult<List<BaseFile>> selectList(BaseFileFilter filter) {
        return BoolResult.success(baseFileService.selectList(filter));
    }

    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "查询系统文件分页列表")
    //@Authorize(code = "basic.baseFile.select")
    @PostMapping("/selectPageList")
    public BoolResult<PageList<BaseFile>> selectPageList(@RequestBody BaseFileFilter filter) {
        return BoolResult.success(baseFileService.selectPageList(filter));
    }
}
